<template>
	<view>
		<!-- 时间 -->
		<view v-if="disabledDate" class="py-2 flex align-center justify-center font-sm text-light-muted">
			{{disabledDate}}
		</view>
		<view class="flex align-start px-2 my-2" :class="{'flex-row-reverse':isSelf}">
			<image 
			:src="item.avatar" style="width: 100rpx; height: 100rpx;" 
			class="rounded-circle"></image>
			<view class="bg-light p-2 rounded mx-2" 
			style="max-width: 400rpx;">
				{{item.content}}
			</view>
		</view>
	</view>
</template>

<script>
	import $T from '@/common/msg_time.js'
	export default{
		props:{
			item:Object,
			index:Number,
			pretime:[Number,String]
		},
		computed:{
			isSelf(){
				return this.item.user===this.$store.state.userInfo.id
			},
			shortTime(){
				// 获取聊天时间（相差300s内的信息不会显示时间）
				return this.item.create_date - this.pretime > 300
			},
			// 消息时间的封装
			disabledDate(){
				// console.log(this)
				let time_obj = $T.disabledDate(this.item.create_date,this.pretime)
				if(time_obj){
					return time_obj.key + time_obj.value	
				}
				return false
				
				
				
			}
		}
	}
</script>

<style>
</style>
